﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using Yule8xCommon.Applib;

namespace Yule8xModel.PageModels
{
    public class AgentIndexPageModels
    {
        public static AgentIndexPageData GetPageData(int user_id)
        {
            // 用户资金账户表和用户资金账户统计表
            DataTable dtUserAccount = UserModels.GetUserFinanceAccountStatistcs(user_id);
            if (dtUserAccount.Rows.Count < 1)
            {
                return null;
            }
            // 用户代理表和用户代理统计表
            DataTable dtAgentStatics = UserModels.GetUserAgentStatistcs(user_id);
            AgentIndexPageData dataObj = new AgentIndexPageData()
            {
                totalAmount = DataTableUtil.GetDecimal(dtUserAccount, "income_amount_total"),
                todayAmount = DataTableUtil.GetDecimal(dtUserAccount, "income_amount_today"),
                agent2Count = DataTableUtil.GetInteger(dtAgentStatics, "child1_agent_count"),
                agent3Count = DataTableUtil.GetInteger(dtAgentStatics, "child2_agent_count"),
                agentType = DataTableUtil.GetInteger(dtAgentStatics, "agent_type"),
                blance = DataTableUtil.GetDecimal(dtUserAccount, "blance"),
                dimondCount = DataTableUtil.GetInteger(dtUserAccount, "diamond_number"),
            };
            return dataObj;
        }
        public class AgentIndexPageData
        {
            /// <summary>
            /// 账户余额
            /// </summary>
            public decimal blance;
            /// <summary>
            /// 今日收入
            /// </summary>
            public decimal todayAmount;
            /// <summary>
            /// 累计收入
            /// </summary>
            public decimal totalAmount;
            /// <summary>
            /// 八星钻石
            /// </summary>
            public int dimondCount;
            /// <summary>
            /// 代理类型
            /// </summary>
            public int agentType;
            /// <summary>
            /// 2级代理
            /// </summary>
            public int agent2Count;
            /// <summary>
            /// 3级代理
            /// </summary>
            public int agent3Count;
        }
    }
}
